home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
How to Get Online 1996 Spring
/
HOW2GON.ISO
/
mac
/
FTP
/
Robert's File Server v1. folder
/
Robert's File Server v1.10
/
For Eudora Pro
/
File server v1.10 (TEXT)
next >
Wrap
Text File
|
1995-10-31
|
8KB
|
190 lines
-- Settings
set eudoraSettings to {alias "Macintosh HD:Documents:file-server Folder:Eudora Settings"}
set pubdir to "Macintosh HD:Accès ARA:De Robert:" -- the folder whare the files are
set indexFile to {alias "Macintosh HD:Accès ARA:De Robert:00index.txt"} -- the files list
set inMailbox to "In" -- the name of the incomming mailbox
set trashMailbox to "Reçus et traités" -- the name of the trash mailbox we want to use
set outMailbox to "Out" -- the name of the outgoing messages
set formsMailbox to "Modèles" -- the name of our forms mailbox
set sysop to "robert" -- who will get the Bcc of error reports if any
set returnPath to "" as string -- initialize
set myType to "" -- initialize
-- First check if Eudora is already running. If so, exit with a nice beep.
-- I don't want the script to throw me out my messages reading when I'm
-- using Eudora. This part of the script requires the GTQ Scripting Library's
-- "Is Application Running" scripting addition.
if (is application running "Eudora Pro") then
beep
return
end if
-- Now the script itself.
tell application "Eudora Pro"
activate
-- If not using the default Eudora's Settings open it here
open eudoraSettings
with timeout of 3600 seconds
-- get the messages from server
connect with checking
-- do we have incomming messages?
set messageCount to (count mailbox named inMailbox of mail folder named "" each message)
if messageCount is not 0 then
-- so process them
set itemNumber to 1
repeat messageCount times
-- get the body of the message
-- we cannot get the body of a message with Eudora Pro (2.13)
-- this part will extract it from the entire message
set messageText to message itemNumber of mailbox named inMailbox of mail folder named ""
set lineCount to (count the paragraphs of messageText)
set lineTodo to 1
-- process each line
repeat lineCount times
set theLine to paragraph lineTodo of messageText
set wordCount to (count the words of theLine)
if wordCount is not 0 then
set myCommand to the first word of theLine
if (myCommand is "path") and (wordCount > 1) then
set returnPath to characters 6 thru (the ¬
length of theLine) of theLine as string
else if myCommand is "AppleDouble" then
set myType to myCommand
else if myCommand is "AppleSingle" then
set myType to myCommand
else if myCommand is "BinHex" then
set myType to myCommand
else if myCommand is "uuencode" then
set myType to myCommand
else if (myCommand is "help") ¬
or (myCommand is "aide") then
-- Instead of attaching a file, we get
-- the content of a saved message and paste
-- it into the reply.
reply message itemNumber of mailbox inMailbox ¬
of mail folder named "" without quoting
if returnPath is not "" then
set field "To:" of message named "" to returnPath
end if
set the field "Subject:" of message named "" to myCommand
-- now get the body of the saved message
-- first locate the message itself
set foundForm to 1
repeat (count mailbox named formsMailbox ¬
of mail folder named "" each message) times
if the field "Subject:" of message foundForm ¬
of mailbox formsMailbox of mail folder "" ¬
contains myCommand then
exit repeat
else
set foundForm to foundForm + 1
end if
end repeat
-- get the body of the message
-- we cannot get the body of a message with Eudora Pro (2.13)
-- this part will extract it from the entire message
-- the body start at a line beginning with "X-Attachments:"
-- (Don't ask me why!!!!)
set myForm to message foundForm of mailbox named formsMailbox of mail folder ""
set myOffset to the offset of "X-Attachments:" in myForm
set myLength to the length of myForm
set myForm to (characters (myOffset + 14) thru myLength of myForm) as text
-- as the length of "X-Attachments:" is 14
-- paste it
set the body of message named "" to myForm
-- send the message
queue message named ""
else if myCommand is "index" then
-- send the "00index.txt" file
reply message itemNumber of mailbox inMailbox ¬
of mail folder named "" without quoting
if returnPath is not "" then
set field "To:" of message named "" to returnPath
end if
set the field "Subject:" of message named "" to "Index"
set the body of message named "" ¬
to ("This is the files list of our file server." ¬
& return & return ¬
& "To receive the help file, put the word «help»" ¬
& " in the body of your message." & return)
if myType is "AppleSingle" then
set attachment encoding of message named "" to AppleSingle
else if myType is "BinHex" then
set attachment encoding of message named "" to BinHex
else if myType is "uuencode" then
set attachment encoding of message named "" to uuencode
else
set attachment encoding of message named "" to AppleDouble
end if
attach to message named "" documents indexFile
queue message named ""
else if (myCommand is "send") and (wordCount > 1) then
-- send a file
reply message itemNumber of mailbox inMailbox ¬
of mail folder named "" without quoting
if returnPath is not "" then
set field "To:" of message named "" to returnPath
end if
-- get the file name
set fName to characters 6 thru (the length of theLine) ¬
of theLine as string
set field "Subject:" of message named "" to fName
try
-- try to attach the file
set the body of message named "" ¬
to "This is the file you requested." & return & return ¬
& "To receive the help file, put the word «help»" ¬
& " in the body of your message, to receive our files list, " ¬
& "put the word «index»." & return
if myType is "AppleSingle" then
set attachment encoding of message named "" to AppleSingle
else if myType is "BinHex" then
set attachment encoding of message named "" to BinHex
else if myType is "uuencode" then
set attachment encoding of message named "" to uuencode
else
set attachment encoding of message named "" to AppleDouble
end if
attach to message named "" documents {alias (pubdir & fName)}
on error errorText
-- the file wasn't there???
set the body of message named "" ¬
to "Error while processing the «send» command for the file: «" ¬
& fName & "», probably because the file doesn't exists." & return ¬
& return & "To receive the help file, put the word «help»" ¬
& " in the body of your message, to receive our files list, " ¬
& "put the word «index»." & return & return ¬
& "The message returned by AppleScript: " & errorText & return
set the field "Bcc:" of message named "" to sysop
end try
queue message named ""
end if
end if
set lineTodo to lineTodo + 1
end repeat
-- re-initialize variables
set returnPath to "" as string
set myType to ""
set itemNumber to itemNumber + 1
end repeat
-- move messages to our trash mailbox
repeat messageCount times
move message 1 of mailbox inMailbox of mail folder named "" ¬
to the end of mailbox trashMailbox of mail folder named ""
end repeat
-- the same for sent messages
-- after sending them
set messageCount to (count mailbox named outMailbox ¬
of mail folder named "" each message)
if (messageCount > 0) then
connect with sending
repeat messageCount times
move message 1 of mailbox outMailbox of mail folder named "" ¬
to the end of mailbox trashMailbox of mail folder named ""
end repeat
end if
end if
quit -- Bye
end timeout
end tell